<div class="col-md-12 col-sm-12 col-xs-12">
    <div class="x_panel">
        <div class="x_title">
            <h2>{$pri_name} <small></small></h2>
            <ul class="nav navbar-right panel_toolbox">
<!--                {:check_create('create',['type_id'=>input('type_id')])}-->
            </ul>
            <div class="clearfix"></div>
        </div>
        <div class="x_content">
            <p class="text-muted font-13 m-b-30">
                <code>说明:</code>{$code}
            </p>
            <form id="search" action="{:url('index')}" />
<!--            {foreach :input() as $key => $value}-->
<!--            <input type="hidden" name="{$key}" class="form-control" value="{$value}">-->
<!--            {/foreach}-->
            <input type="hidden" name="page" value="1"/>
            <div class="well" style="overflow: auto">
                <div class="col-md-2">
                    <input type="text" name="title" autocomplete="off" class="form-control" placeholder="请输入搜索内容..." value="{:input('title')}">
                </div>
                <div class="col-md-2">
                    <select name="level_id" class="select2 js-states form-control" style="width: 100%;">
                        <option value="-1">全部级别</option>
                        {volist name="$level_data" id="item"}
                        <option value="{$item.id}" {eq name=":input('level_id',-1)" value="$item.id"}selected{/eq}>{$item.title}</option>
                        {/volist}
                    </select>
                </div>
                <div class="col-md-2">
                    <input type="text" name="create_time" autocomplete="off" class="form-control" id="interval_timer" style="width: 100%" placeholder="请选择时间区间..." value="{:input('create_time')}">
                </div>

                <div class="col-md-1">
                    <button type="submit" class="btn btn-success">搜 索</button>
                </div>
            </div>
            </form>
            <div style="overflow: auto">
                <table id="datatables" class="table table-striped table-bordered">
                    <thead>
                    <tr>
                        <!--<th><input type="checkbox" onclick="CheckAll(this.checked)"></th></th>-->
                        <th>
                        <input type="checkbox" onclick="CheckAll(this.checked)"></th>
                    </th>
                        <th width="40" style="text-align: center;">ID</th>
                        <th>邀请码</th>

                        <th>手机号</th>

                        <th>昵称</th>
                        <th>头像</th>
                        <th>上级会员ID</th>
                        <th>上级会员邀请码</th>
                        <th>上级会员手机号</th>
                        <th>积分</th>
                        <th>佣金</th>
                        <th>会员级别</th>
                        <th>团队人数</th>
                        <th width="140">创建时间</th>
                        <th>密码</th>
                        <th width="130">操作</th>
                    </tr>
                    </thead>

                    <form id="form_volist">
                     <tbody>
                        {volist name="data" id="vo"}
                        <tr>
                            <th width="20">
                        <input type="checkbox" name="id[]" value="{$vo.id}"/>
                        </th>
                            <td width="40" style="text-align: center;">{$vo.id}</td>
                            <td>{$vo.invite_code}</td>
                            <td>{$vo.mobile}</td>

                            <td>{$vo.nickname}</td>
                            <td width="60" align="center"><img  height="25" src="{$vo.headimgurl}" /></td>
                            <td>{$vo.parent_id}</td>
                            <td>{$vo.parent_invite_code}</td>
                            <td>{$vo.parent_mobile}</td>
                            <td>{$vo.integral}</td>
                            <td>{$vo.brokerage}</td>
                            <td>{$vo.level_name}</td>
                            <td>{$vo.team_count}</td>
                            <td>{$vo.create_time}</td>
                            <td>{$vo.password}</td>
                            <td>

                                <button style="background-color: #009688;border:1px solid #009688" class="more btn btn-info btn-xs" data-member_id="{$vo.id}">更多操作</button>
                                {:diy_button('my_parent',['member_id'=>$vo.id],['style'=>'btn-primary','size'=>'btn-xs','a'=>true,'attr'=>['id'=>$vo.id,'company_id'=>$vo.company_id,'title'=>$vo.title,'project_id'=>$vo.project_id]])}
                                {:diy_button('my_son',['parent_id'=>$vo.id],['style'=>'btn-primary','size'=>'btn-xs','a'=>true,'attr'=>['id'=>$vo.id,'company_id'=>$vo.company_id,'title'=>$vo.title,'project_id'=>$vo.project_id]])}
                                {:check_update('update',['id' => $vo.id])}
                                {:check_destory('destory',['id' => $vo.id])}
                            </td>
                        </tr>

                        {/volist}
                    </tbody>
                    </form>

                        <script>
                            $('#upload').click(function () {
                                $("#read").submit();
                            });
                        </script>
                    <tfoot align="left">
                    <tr>
                        <td colspan="100">
                            <span>控制：</span>
                            <a href="{:session(request()->controller().'_url_excel')}" style="color:#428BCA;cursor: pointer" >导出数据</a>
<!--                            <a style="color:#428BCA;cursor: pointer" onclick="index_update('{:url(\'index_update\')}')">更新排序</a>-->
                        </td>
                    </tr>
                    </tfoot>
                </table>
            </div>
            <div>
               会员数量:{$count}  会员积分:{$integral}  会员佣金:{$brokerage}
            </div>
<!--            <div align="center">-->
<!--                <span class="btn btn-success fileinput-button" style="float: left;">-->
<!--                    <span>导入Excel</span>-->
<!--                    <input type="file" name="excel" id="myform">-->
<!--                </span>-->
<!--            </div>-->
            <div style="text-align: right;">{$data|raw}</div>
        </div>
    </div>
</div>

<!--<link rel="stylesheet" href="//unpkg.com/layui@2.6.8/dist/css/layui.css">-->
<!--<script src="//unpkg.com/layui@2.6.8/dist/layui.js"></script>-->

<!-- 引入 layui.css -->
<link rel="stylesheet" href="__PLUGIN__/layui-master/dist/css/layui.css">
<script src="__PLUGIN__/layui-master/dist/layui.js"></script>

<!--<table class="layui-table">-->

<!--    <tbody>-->

<!--    <tr>-->

<!--        <td>列表 1</td>-->

<!--        <td><button class="layui-btn layui-btn-sm demolist" data-id="111">更多操作</button></td>-->

<!--    </tr>-->

<!--    <tr>-->

<!--        <td>列表 2</td>-->

<!--        <td><button class="layui-btn layui-btn-sm demolist" data-id="222">更多操作</button></td>-->

<!--    </tr>-->

<!--    <tr>-->

<!--        <td>列表 3</td>-->

<!--        <td><button class="layui-btn layui-btn-sm demolist" data-id="333">更多操作</button></td>-->

<!--    </tr>-->

<!--    </tbody>-->
<!--</table>-->
<!-- 引入 layui.css -->

<script>
    layui.use('dropdown', function(){
        var dropdown = layui.dropdown
            ,$ = layui.jquery;

        dropdown.render({
            elem: '.more'
            ,data: [
            //     {
            //     title: '积分充值'
            //     ,type: 'integral_recharge'
            // },
                {
                title: '会员级别'
                ,type: 'update_level'
            },    {
                    title: '修改推荐人'
                    ,type: 'update_parent'
                },    {
                    title: '批量添加直推'
                    ,type: 'create_son'
                }
            ]
            ,click: function(data, othis){ //data下单菜单
                var elem = $(this.elem)
                    ,member_id = elem.data('member_id'); //表格列表的预埋数据
                //layer.msg('得到表格列表的 member_id：'+ member_id +'，下拉菜单 id：'+ data.id);
                $('.layui-layer-content').find('input').attr('min',1);
                if(data.type == 'integral_recharge'){
                    layer.prompt({title:'充值积分'},function(val, index){ //当前值val
                        $.ajax({
                            type: "POST", //用POST方式传输
                            dataType: "json", //数据格式:JSON
                            data:{token:member_id,integral:val},
                            url: "{:url('integral_recharge')}", //目标地址
                            async: false,
                            success: function (ret) {
                                if(ret.code == 200){
                                    layer.msg(ret.msg);
                                    layer.close(index);
                                    // layer.msg(data.message);
                                    return false;
                                }else{
                                    layer.msg(ret.msg);
                                    return false;
                                }
                            }
                        });

                    });
                }
                if(data.type == 'update_parent'){
                    layer.prompt({title:'修改推荐人'},function(val, index){ //当前值val
                        $.ajax({
                            type: "POST", //用POST方式传输
                            dataType: "json", //数据格式:JSON
                            data:{member_id:member_id,mobile:val},
                            url: "{:url('update_parent')}", //目标地址
                            async: false,
                            success: function (ret) {
                                if(ret.code == 200){
                                    layer.msg(ret.msg);
                                    layer.close(index);
                                    history.go(0);
                                    // layer.msg(data.message);
                                    return false;
                                }else{
                                    layer.msg(ret.msg);
                                    return false;
                                }
                            }
                        });

                    });
                }
                //以后积分充值
                if(data.type == 'update_level'){

                    layer.open({

                        btn: ['确认','取消'],

                        title:['操作'],
                        yes: function(index, layero){
                            //do something
                            var lev =$('#lev').val();

                            $.ajax({

                                type: 'post',

                                url: "{:url('update_level')}", //目标地址

                                data:{member_id:member_id,level_id:lev},

                                success: function (response) {

                                    if(response.code==200){

                                        layer.close(layer.index);

                                        history.go(0);

                                        layer.alert(response.msg, {icon: 6, time: 3000});

                                    }else{

                                        layer.close(layer.index);

                                        layer.alert(response.msg, {icon: 2, time: 3000});

                                    }



                                    form.render('select');

                                }

                            })
                            layer.close(index); //如果设定了yes回调，需进行手工关闭
                        },


                    }
                    );
                    $(".layui-layer-content").append("	<br/><div class='layui-inline'>  <div class=\"layui-inline\">\n" +

                        "                    <label class=\"layui-form-label\">级别</label>\n" +

                        "                    <div class=\"layui-input-inline\"  style=\"width: auto;\">\n" +

                        "                        <select name='level_id' id='lev' style='height: 30px'   lay-filter=\"lev\">\n" +

                        "                            <option value=\"0\">游客</option>\n" +

                        "                            <option value=\"1\">会员</option>\n" +

                        "                            <option value=\"2\">经销商</option>\n" +

                        "                            <option value=\"3\">总代理</option>\n" +


                        "\n" +

                        "                        </select>\n" +

                        "                    </div>\n" +

                        "                </div></div> </div>");
                }

                if(data.type == 'create_son'){

                    layer.open({

                            btn: ['确认','取消'],

                            title:['操作'],
                            yes: function(index, layero){
                                //do something
                                var son =$('#son').val();
                                var level_id =$('#lev').val();
                                $.ajax({

                                    type: 'post',

                                    url: "{:url('create_son')}", //目标地址

                                    data:{parent_id:member_id,son:son,level_id:level_id},

                                    success: function (response) {

                                        if(response.code==200){

                                            layer.close(layer.index);

                                            history.go(0);

                                            layer.alert(response.msg, {icon: 6, time: 3000});
                                            layer.close(index);
                                        }else{

                                           // layer.close(layer.index);

                                            // layer.alert(response.msg, {icon: 2, time: 3000});
                                            layer.msg(response.msg);

                                        }



                                        form.render('select');

                                    }

                                })
                                //layer.close(index); //如果设定了yes回调，需进行手工关闭
                            },


                        }
                    );
                    $(".layui-layer-content").append("<div class='layui-inline'>  <div class=\"layui-inline\">\n" +

                        "                    <label class=\"layui-form-label\">级别</label>\n" +

                        "                    <div class=\"layui-input-inline\"  style=\"width: auto;\">\n" +

                        "                        <select id='lev' style='height: 30px'   lay-filter=\"lev\">\n" +

                        "                            <option value=\"0\">游客</option>\n" +

                        "                            <option value=\"1\">会员</option>\n" +

                        "                            <option value=\"2\">经销商</option>\n" +

                        "                            <option value=\"3\">总代理</option>\n" +


                        "\n" +

                        "                        </select>\n" +

                        "                    </div>\n" +

                        "                </div></div> </div><textarea id='son' style='height: 200px; width: 100%'></textarea>");
                }

            }
        });
    });
</script>